package com.tianji.learning.controller;

import com.tianji.learning.domain.dto.AddNotesDto;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tianji.common.domain.dto.PageDTO;
import com.tianji.learning.domain.query.UserNoteQuery;
import com.tianji.learning.domain.vo.UserNotePageVo;
import org.springframework.web.bind.annotation.*;
import com.tianji.learning.service.INoteService;
import com.tianji.learning.domain.po.Note;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RestController;
import com.tianji.learning.domain.dto.UpdateNoteDto;
import com.tianji.learning.service.INoteService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.xml.transform.Result;

/**
 * <p>
 * 课程笔记表 控制器
 * </p>
 *
 * @author auth
<<<<<<< HEAD
 * @author lvbin
=======
 * @author 张政
>>>>>>> origin/zhangzheng
 * @author L.HS
 * @author chuanyun
 * @author author
 */
@Api(tags = "Note管理")
@RestController
@RequiredArgsConstructor
@RequestMapping("/notes")
public class NoteController {

    private final INoteService noteService;


    @ApiOperation("3.1.2.采集采集笔记")
    @PostMapping("/gathers/{id}")
    public void gatherNotes(@PathVariable("id")Long id){
        noteService.gatherNotes(id);
    }

    @ApiOperation("3.1.2.取消采集笔记")
    @DeleteMapping("/gathers/{id}")
    public void deleteNotes(@PathVariable("id")Long id){
        noteService.deleteNotes(id);
    }


    @ApiOperation("编辑学习笔记")
    @PutMapping("/{id}")
    public void editNote(@PathVariable("id") Long id, @RequestBody UpdateNoteDto dto) {
        noteService.editNote(id, dto);
    }

    @ApiOperation("删除学习笔记")
    @DeleteMapping("/{id}")
    public void deleteNote(@PathVariable("id") Long id) {
        noteService.deleteNote(id);
    }
    @PostMapping
    @ApiOperation("新增笔记")
    public void addNotes(@RequestBody AddNotesDto dto) {
        noteService.addNotes(dto);
    }

    @GetMapping("/page")
    public PageDTO<UserNotePageVo> pageQuery( UserNoteQuery query){
        return noteService.pageQuery(query);
    }
}
